/*
* @Author: Rosen
* @Date:   2018-02-05 13:14:41
* @Last Modified by:   Rosen
* @Last Modified time: 2018-02-05 13:16:56
*/
import React        from 'react';

//快递公司选择


class Expressage extends React.Component{
    constructor(props){
        super(props);
        this.state = {
            searchName      : '', 
            searchKeyword   : ''
        }
    }
    // 数据变化的时候
     onValueChange(e){
        let name    = e.target.name,
            value   = e.target.value.trim();
        this.setState({
            [name] : value
        });

    }
    // 点击发货按钮的时候
    onSearch(){
let myselect=document.getElementById("select");
let index=myselect.selectedIndex ;//获取索引，下面的text获取值
        this.props.ch(myselect.options[index].text, this.state.searchKeyword);
    }
    // 输入关键字后按回车，自动提交
    onSearchKeywordKeyUp(e){
        if(e.keyCode === 13){
            this.onSearch();
        }
    }
    render(){
        return (
            <div className="row search-wrap">
                <div className="col-md-12">
                    <div className="form-inline">
                        <div className="form-group">
                                    <select className="form-control cate-select"
                                  placeholder="请输入订单号"
                                name="searchName" id="select" 
                                >
                                   <option >请选择快递公司</option>
                                <option >圆通</option>
                                <option >申通</option>
                                <option >中通</option>
                                   <option >韵达</option>
                                      <option >百世汇通</option>
                                         <option >顺丰</option>
                                          
                            </select>
                           
                        </div>
                         <div className="form-group">
                            <input type="text" 
                                className="form-control" 
                                placeholder="请输入订单号"
                                name="searchKeyword"
                                onKeyUp={(e) => this.onSearchKeywordKeyUp(e)}
                                onChange={(e) => this.onValueChange(e)}/>
                        </div>
                        <div>
                        <button className="btn btn-primary" 
                            onClick={(e) => this.onSearch()}>发货</button>
                            </div>
                    </div>
                </div>
            </div>
        )
    }
}
export default Expressage;